<?php
namespace app\api\controller;
use think\Controller;
use app\api\model\Issue;

class Issues extends Controller{

    public function index(){
        if (request()->isGet()){
            AjaxReturn('10020','传值方式错误');
            die;
        }
        if(request()->isPost()) {
            $ispre = input('ispre');
            $Issue = new Issue;
            $results = $Issue->index($ispre);
            if ($results == 0) {
                AjaxReturn('10011', '暂无商品信息');
            } else {
                AjaxReturn('1', '成功', ['data' => $results]);
            }
        }
    }

    public function details()
    {
        if (request()->isGet()){
            AjaxReturn('10020','传值方式错误');
            die;
        }
        if(request()->isPost()) {
            $id = input('id');
            $issue = new Issue;
            $data = $issue->details($id);
            if ($data['id'] == '' ){
                AjaxReturn('10012', '该商品暂无详细信息');
            } else {
                AjaxReturn('1', '成功', ['details' => $data]);
            }
        }
    }
}